%% Table D1
clear tab
tab=csvread('../temp/level_data.csv');
tab=[nan(1,2); tab(1:2,:); nan(1,2); tab(3:5,:)];

colNames={'NonCollege','College'};
rowNames={};
rowNames{end+1,1}='A. Single Mothers';
rowNames{end+1,1}='Mother''s Time Investment';
rowNames{end+1,1}='Mother''s Hours Worked';
rowNames{end+1,1}='B. Two-Parent Households';
rowNames{end+1,1}='Mother''s Time Investment';
rowNames{end+1,1}='Mother''s Hours Worked';
rowNames{end+1,1}='Father''s Hours Worked';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/TableD1.csv');

%% Table D2
clear tab
tab=csvread('../temp/level_param.csv');
tab=[nan(1,2); tab(1:2,:); nan(1,2); tab(3:5,:)];

colNames={'NonCollege','College'};
rowNames={};
rowNames{end+1,1}='A. Single Mothers';
rowNames{end+1,1}='alpha';
rowNames{end+1,1}='psi_m';
rowNames{end+1,1}='B. Two-Parent Households';
rowNames{end+1,1}='alpha';
rowNames{end+1,1}='psi_m';
rowNames{end+1,1}='psi_f';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/TableD2.csv');

%% Table 6
clear tab0 tab
tab0=csvread('../temp/doutcome_baseline.csv');
tab=tab0(:,2);
tab0=csvread('../temp/doutcome_equal_wage.csv');
tab=[tab tab0(:,2)];
tab0=csvread('../temp/doutcome_equal_wage_price.csv');
tab=[tab tab0(:,2)];
tab0=csvread('../temp/doutcome_equal_tech.csv');
tab=[tab tab0(:,2)];
tab0=csvread('../temp/doutcome_equal_pref.csv');
tab=[tab tab0(:,2)];
tab=[nan(2,5); tab(1:4,:); nan(2,5); tab(8:11,:)];

colNames={'Baseline','Wages','AllPrices','Technology','Preferences'};
rowNames={};
rowNames{end+1,1}='A. Single Mothers';
rowNames{end+1,1}='Total Investment';
rowNames{end+1,1}=' Expenditure';
rowNames{end+1,1}=' Price';
rowNames{end+1,1}=' Quantity';
rowNames{end+1,1}='Mother''s Time Investment';
rowNames{end+1,1}='B. Two-Parent Households';
rowNames{end+1,1}='Total Investment';
rowNames{end+1,1}=' Expenditure';
rowNames{end+1,1}=' Price';
rowNames{end+1,1}=' Quantity';
rowNames{end+1,1}='Mother''s Time Investment';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/Table6.csv');

%% Table 7

clear tab0 tab
tab0=csvread('../temp/change_W_30.csv');
tab=[tab0(:,1); tab0(:,2)];
tab0=csvread('../temp/change_W_constant_full_income_30.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];
tab0=csvread('../temp/change_p_30.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];
tab0=csvread('../temp/change_P_c_30.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];

tab0=csvread('../temp/change_W_30_Cobb_Douglas.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];
tab0=csvread('../temp/change_W_constant_full_income_30_Cobb_Douglas.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];
tab0=csvread('../temp/change_p_30_Cobb_Douglas.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];
tab0=csvread('../temp/change_P_c_30_Cobb_Douglas.csv');
tab=[tab [tab0(:,1); tab0(:,2)]];

tab=[nan(2,8); tab([1 3 5:7],:); nan(1,8); tab([10:11],:); nan(2,8); tab([12 14:18],:); nan(1,8); tab([21:22],:)];

colNames={'Wages','Wages_ConstantIncome','Goods','ChildCare','Wages_CD','Wages_ConstantIncome_CD','Goods_CD','ChildCare_CD'};
rowNames={};
rowNames{end+1,1}='A. Single Mothers';
rowNames{end+1,1}='Change in Investment at Age 5';
rowNames{end+1,1}=' Total Expenditure';
rowNames{end+1,1}=' Mother''s Time';
rowNames{end+1,1}=' Goods';
rowNames{end+1,1}=' Child Care';
rowNames{end+1,1}=' Total';
rowNames{end+1,1}='Effects on Age 13 Achievement';
rowNames{end+1,1}=' 100*Log Achievement';
rowNames{end+1,1}=' Value';
rowNames{end+1,1}='B. Two-Parent Households';
rowNames{end+1,1}='Change in Investment at Age 5';
rowNames{end+1,1}=' Total Expenditure';
rowNames{end+1,1}=' Mother''s Time';
rowNames{end+1,1}=' Father''s Time';
rowNames{end+1,1}=' Goods';
rowNames{end+1,1}=' Child Care';
rowNames{end+1,1}=' Total';
rowNames{end+1,1}='Effects on Age 13 Achievement';
rowNames{end+1,1}=' 100*Log Achievement';
rowNames{end+1,1}=' Value';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/Table7.csv');

%% Table D3

changes=[10 30 50];

for j=1:3
    
    val=int2str(changes(j));
    
    clear tab0 tab
    tab0=csvread(['../temp/change_W_' val '.csv']);
    tab=[tab0(7,1); tab0(7,2)];
    tab0=csvread(['../temp/change_W_constant_full_income_' val '.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    tab0=csvread(['../temp/change_p_' val '.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    tab0=csvread(['../temp/change_P_c_' val '.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];

    tab0=csvread(['../temp/change_W_' val '_Cobb_Douglas.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    tab0=csvread(['../temp/change_W_constant_full_income_' val '_Cobb_Douglas.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    tab0=csvread(['../temp/change_p_' val '_Cobb_Douglas.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    tab0=csvread(['../temp/change_P_c_' val '_Cobb_Douglas.csv']);
    tab=[tab [tab0(7,1); tab0(7,2)]];
    eval(['tab'  val '=-tab./' val ';']);

end

clear tab
tab=[tab10(1,:); tab30(1,:); tab50(1,:); tab10(2,:); tab30(2,:); tab50(2,:)];
tab=[tab (tab(:,5:8)./tab(:,1:4)-1)*100];
tab=[nan(1,12); tab(1:3,:); nan(1,12); tab(4:6,:)];

colNames={'Wages','Wages_ConstantIncome','Goods','ChildCare','Wages_CD','Wages_ConstantIncome_CD','Goods_CD','ChildCare_CD','Wages_diff','Wages_ConstantIncome_diff','Goods_diff','ChildCare_diff'};
rowNames={};
rowNames{end+1,1}='A. Single Mothers';
rowNames{end+1,1}='10% Change';
rowNames{end+1,1}='30% Change';
rowNames{end+1,1}='50% Change';
rowNames{end+1,1}='B. Two-Parent Households';
rowNames{end+1,1}='10% Change';
rowNames{end+1,1}='30% Change';
rowNames{end+1,1}='50% Change';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/TableD3.csv');

%% Table D7

clear tab0 tab
tab0=csvread('../temp/outcome_no_free_childcare.csv');
tab=tab0;
tab0=csvread('../temp/outcome_free_childcare.csv');
tab=[tab(:,1) tab0(:,1) tab(:,2)];

tab0=csvread('../temp/outcome_no_free_childcare_Cobb_Douglas.csv');
tab=[tab tab0];
tab0=csvread('../temp/outcome_free_childcare_Cobb_Douglas.csv');
tab=[tab(:,1:4) tab0(:,1) tab(:,5)];

tab(1:2,[1 3:4 6])=nan;
tab=[nan(1,6); tab(1:2,:); nan(1,6); tab([3:4 6:7],:)];

colNames={'NonCollege_Baseline','NonCollege_Freecare','College','NonCollege_Baseline_CD','NonCollege_Freecare_CD','College_CD'};
rowNames={};
rowNames{end+1,1}='Free Child Care:';
rowNames{end+1,1}=' Public Expenditure';
rowNames{end+1,1}=' Quantity';
rowNames{end+1,1}='Investment Quantities:';
rowNames{end+1,1}='Total';
rowNames{end+1,1}='Mother''s Time';
rowNames{end+1,1}='Goods';
rowNames{end+1,1}='Child Care';

tab=array2table(tab,'VariableNames',colNames);
NewColumn = table(rowNames);
tab=[NewColumn, tab];
writetable(tab, '../../../../output/tables/TableD7.csv');
